﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Customers;

namespace PMS.Data.EntityMap.Customers
{
    /// <summary>
    /// Represents a customer password mapping configuration
    /// </summary>
    public partial class CustomerPasswordMap : PMSEntityTypeConfiguration<CustomerPassword>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<CustomerPassword> builder)
        {
            builder.ToTable("bus_customerpassword");
            builder.HasKey(password => password.Id);

            builder.Property(password => password.Password).HasMaxLength(5000).IsRequired();
            builder.Property(password => password.PasswordSalt).HasMaxLength(1024);
            builder.Property(mapping => mapping.CustomerId).IsRequired();
            builder.Property(password => password.PasswordStrongLevel).IsRequired();
            builder.Property(password => password.IsActive).IsRequired();
            builder.Property(password => password.CreatedOnTimeUtc).IsRequired();
            builder.Property(password => password.UpdatedOnTimeUtc).IsRequired();

            //builder.HasOne(password => password.Customer)
            //    .WithOne(customer => customer.Password)
            //    .HasForeignKey<CustomerPassword>(password => password.CustomerId)
            //    .IsRequired();

            builder.Ignore(password => password.PasswordFormat);

            base.Configure(builder);
        }

        #endregion
    }
}
